﻿<?php
// ------------------------------------------------------------------
// WHAT DOES THIS EXAMPLE DO?
// ------------------------------------------------------------------
// At last, a ClickDigitizer is only a normal DeclareMap24Location, but with some
// customized settings.
// If this example is exeuted, there will be no visible location on the map,
// but everytime it is clicked in the map the defined url of the added location will be called.
// In this url special placeholders can be defined, e.g. ${LONGITUDE} ${LATITUDE}, which will
// be replaced with the coordinates of the point it was clicked on.
// In this case the defined url is another http-get-request that adds a location to the
// clicked point.

// ------------------------------------------------------------------
// NEEDED STUBS FOR THIS EXAMPLE
// ------------------------------------------------------------------


// this will include all needed files to be able to build a Request
include_once($CONF["STUBS_FOLDER"]."Map24MapletRemoteControl/Map24MapletRemoteControl.php5");


// ------------------------------------------------------------------
// NEEDED PARAMETERS FOR THIS REQUEST
// ------------------------------------------------------------------


// coordinates of the location to add
$longitude 	= "500";
$latitude 	= "3000";

// try this examples too
//$url = "http://www.google.de";
//$url = 'javascript:alert("${LONGITUDE} : ${LATITUDE}");';
$url = 'http://'. $CONF['MAPTP_SYSTEM'].'/map24/webservices1.5?cmd0=ADD&id0=${LONGITUDE}${LATITUDE}&x0=${LONGITUDE}&y0=${LATITUDE}&symbol_id0=3&cmd1=ENABLE&mobid1=${LONGITUDE}${LATITUDE}&mid='.$CONF['MAP24_ID'].'&sid='.$CONF['SESSION_ID'].'&cgi=Map24MapletRemoteControl';

// symbol used 	to display the location
$symbolId	= "1";

// zoomlevel
$mapViewClippingWidth = 5000;


// ------------------------------------------------------------------
// BUILDING THE REQUEST
// ------------------------------------------------------------------


// here are all commands defined and are put together in one ArrayOfCommands

// this object will add a new location/digitizer
$cmdIdx=0;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->DeclareMap24Location = new DeclareMap24Location();
$commands[$cmdIdx]->DeclareMap24Location->MapObjectID = "digitizer";
$commands[$cmdIdx]->DeclareMap24Location->Coordinate = new Coordinate();
$commands[$cmdIdx]->DeclareMap24Location->Coordinate->Longitude = $longitude;
$commands[$cmdIdx]->DeclareMap24Location->Coordinate->Latitude = $latitude;
$commands[$cmdIdx]->DeclareMap24Location->URL = $url;
$commands[$cmdIdx]->DeclareMap24Location->TargetFrame = "_map24applet";   //"_map24applet"; für Applet
$commands[$cmdIdx]->DeclareMap24Location->SymbolID = $symbolId;
$commands[$cmdIdx]->DeclareMap24Location->Customize = new MapObjectCustomSettings();
$commands[$cmdIdx]->DeclareMap24Location->Customize->Handler = "MAP24_CLICK";
$commands[$cmdIdx]->DeclareMap24Location->Customize->Properties[0] = new Property();
$commands[$cmdIdx]->DeclareMap24Location->Customize->Properties[0]->Key = "CLICK";
$commands[$cmdIdx]->DeclareMap24Location->Customize->Properties[0]->Value = "left_click";

// this object will enable the new location on the map
$cmdIdx++;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->ControlMapObject = new ControlMapObject();
$commands[$cmdIdx]->ControlMapObject->Control = "ENABLE";
$commands[$cmdIdx]->ControlMapObject->MapObjectIDs = array("digitizer");

// this object will center the map above the new location
$cmdIdx++;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->SetMapView = new SetMapView();
$commands[$cmdIdx]->SetMapView->MapObjectIDs = array("digitizer");
$commands[$cmdIdx]->SetMapView->ClippingWidth = new SetMapViewClippingWidth();
$commands[$cmdIdx]->SetMapView->ClippingWidth->MinimumWidth = $mapViewClippingWidth;


// definition of the request header with Map24ID and SessionID
$header = new RequestHeader();
$header->Map24ID  = $CONF['MAP24_ID'];
$header->ClientID = $CONF['SESSION_ID'];

// definition of the request body
$request = new MapletRemoteControlRequest();
$request->Map24MRC = new Map24MRC();
$request->Map24MRC->Commands = $commands;


// ------------------------------------------------------------------
// EXECUTE THE REQUEST
// ------------------------------------------------------------------


// in this object the SoapClient will be initiated and executed
$mrc = new Map24MapletRemoteControl($CONF['MAPTP_SYSTEM'],$CONF['MAP24_ID'],$CONF['SESSION_ID']);
$response = $mrc->mapletRemoteControl($header,$request);


// ------------------------------------------------------------------
// OUTPUT THE RESULT
// ------------------------------------------------------------------


$resultString = "This command generates no output";
$counter = 0;

?>